/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Reynusa
 */
public class Pesanan {

    private String KodeBarang;
    private String NamaBarang;
    private String JenisBarang;
    private int JumlahBarang;
    private double HargaBarang;
    private String KodeToko;
    private String Tgl_pesanan;

    public String getTgl_pesanan() {
        return Tgl_pesanan;
    }

    public void setTgl_pesanan(String Tgl_pesanan) {
        this.Tgl_pesanan = Tgl_pesanan;
    }
    

    public double getHargaBarang() {
        return HargaBarang;
    }

    public void setHargaBarang(double HargaBarang) {
        this.HargaBarang = HargaBarang;
    }

    public String getJenisBarang() {
        return JenisBarang;
    }

    public void setJenisBarang(String JenisBarang) {
        this.JenisBarang = JenisBarang;
    }

    public int getJumlahBarang() {
        return JumlahBarang;
    }

    public void setJumlahBarang(int JumlahBarang) {
        this.JumlahBarang = JumlahBarang;
    }

    public String getKodeBarang() {
        return KodeBarang;
    }

    public void setKodeBarang(String KodeBarang) {
        this.KodeBarang = KodeBarang;
    }

    public String getKodeToko() {
        return KodeToko;
    }

    public void setKodeToko(String KodeToko) {
        this.KodeToko = KodeToko;
    }

    public String getNamaBarang() {
        return NamaBarang;
    }

    public void setNamaBarang(String NamaBarang) {
        this.NamaBarang = NamaBarang;
    }

  

    public Pesanan() {
    }

    public List tampilpesanan(String kodetoko) throws SQLException {
        List listpesanan = new ArrayList();
        Connection conn = DatabaseConnect.open("jdbc:oracle:thin:@172.23.9.185:1521:orcl", "mhs125314075", "mhs125314075");
//        Connection conn = DatabaseConnect.open("jdbc:oracle:thin:@localhost:1521:xe", "reynusa", "reynusa");
        Statement st = conn.createStatement();
        String daftarpesanan = "select * from DAFTARPESANAN where KODETOKO='" + kodetoko + "'";
        ResultSet rs = st.executeQuery(daftarpesanan);
        while (rs.next()) {
            Pesanan pesananx = new Pesanan();
            pesananx.setKodeBarang(rs.getString("KODETOKO"));
            pesananx.setKodeBarang(rs.getString("KODEBARANG"));
            pesananx.setNamaBarang(rs.getString("NAMABARANG"));
            pesananx.setJenisBarang(rs.getString("JENISBARANG"));
            pesananx.setHargaBarang(rs.getDouble("HARGABARANG"));
            pesananx.setJumlahBarang(rs.getInt("JUMLAH"));
            pesananx.setTgl_pesanan(rs.getString("TGL_PESANAN"));
            listpesanan.add(pesananx);
        }

        conn.commit();
        return listpesanan;
    }
}
